import { createWebHistory, createRouter } from 'vue-router';
import Layout from '@/layout';

export const constantRoutes = [
    {
        path: '/about',
        name: 'about',
        component: () => import('@/views/about/index'),
        meta: { title: '关于我们', icon: 'dashboard' }
    },
    {
        path: '/login',
        name: 'login',
        component: () => import('@/views/login/index'),
        meta: { title: '登录', icon: 'dashboard' }
    },
    {
        path: '/',
        component: () => import('@/layout/index.vue'),
        children: [
            {
                path: '/charger',
                component: () => import('@/views/chargeType/charger/charger.vue'),
                meta: { title: '充电机记录', id: '211', pid: '21' }
            },
            {
                path: 'letter',
                name: 'letter',
                component: () => import('@/views/chargeType/charger/letter.vue'),
                meta: { title: '遥信数据', id: '212', pid: '21' }
            },
            {
                path: 'measure',
                name: 'measure',
                component: () => import('@/views/chargeType/charger/measure.vue'),
                meta: { title: '遥测数据', id: '213', pid: '21' }
            },
            {
                path: 'energy',
                name: 'energy',
                component: () => import('@/views/chargeType/charger/energy.vue'),
                meta: { title: '充电机-充电', id: '214', pid: '21' }
            },
            {
                path: 'control',
                name: 'control',
                component: () => import('@/views/chargeType/charger/control.vue'),
                meta: { title: '充电机-控制', id: '215', pid: '21' }
            },
            {
                path: 'waterCooling',
                name: 'waterCooling',
                component: () => import('@/views/chargeType/waterCooler/waterCooling.vue'),
                meta: { title: '水冷机组', id: '22', pid: '2' }
            },
            {
                path: 'agv',
                name: 'agv',
                component: () => import('@/views/chargeType/agv/agv.vue'),
                meta: { title: 'AGV充电', id: '23', pid: '2' }
            }
        ]
    }
];

const router = createRouter({
    history: createWebHistory(),
    routes: constantRoutes,
    scrollBehavior(to, from, savedPosition) {
        if (savedPosition) {
            return savedPosition;
        } else {
            return { top: 0 };
        }
    }
});

export default router;
